package com.lizardmind.haofudoctor.ui.aboutMe

import android.arch.lifecycle.ViewModelProviders
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.linxiao.framework.fragment.BaseFragment
import com.linxiao.framework.util.getDataBinding
import com.linxiao.framework.util.intent
import com.lizardmind.haofudoctor.R
import com.lizardmind.haofudoctor.databinding.FragmentAboutmeBinding
import com.lizardmind.haofudoctor.ui.aboutMe.editData.EditDataActivity
import com.lizardmind.haofudoctor.ui.aboutMe.set.SetActivity
import kotlinx.android.synthetic.main.fragment_aboutme.*
import kotlinx.android.synthetic.main.include_title_text.view.*
import org.jetbrains.anko.sdk25.coroutines.onClick
import org.jetbrains.anko.support.v4.intentFor
import org.jetbrains.anko.support.v4.toast

/**
 * 关于我
 * Created by Extends on 2017/10/13 13:10
 */
class AboutMeFragment: BaseFragment() {
    val binding by lazy { getDataBinding<FragmentAboutmeBinding>(R.layout.fragment_aboutme) }
    override fun onCreatRootView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View =binding.root

    override fun onInitView(savedInstanceState: Bundle?) {
        rootView.apply {
            aboutme_title.titleText.text = "我的"
            release.onClick { startActivity(intent<MyPublishActivity>()) }
            aboutme_userLayout.onClick { startActivity(intentFor<EditDataActivity>()) }
            release.onClick { startActivity(intent<MyPublishActivity>()) }
            collection.onClick { startActivity(intent<CollectActivity>()) }
            download.onClick { toast("没有设计图") }
            setting.onClick { startActivity(intent<SetActivity>()) }
            feedback.onClick { startActivity(intent<FeedbackActivity>()) }
            recommend.onClick { toast("没有设计图") }
            about.onClick { toast("没有设计图") }
        }
        binding.apply {
            vm = ViewModelProviders.of(this@AboutMeFragment).get(AboutMeVM::class.java)
            lifecycle.addObserver(vm!!)
        }
    }
}